<template>
  <div>
    <ul class="mui-table-view">
        <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
            <router-link :to="'/home/newslist/'+item.id">
                <img class="mui-media-object mui-pull-left" :src="item.img_url">
                <div class="mui-media-body">
                    <h3 class="item-title"> {{item.title}} </h3>
                    <p class='mui-ellipsis'><span>发表时间：{{item.add_time | dataFrom }}</span> <span>点击：{{item.click}}次</span></p>
                </div>
            </router-link>
        </li>
    </ul>

  </div>
</template>



<script>
// 导入提示信息组件
import { Toast } from 'mint-ui'

export default {
    data(){
        return{
            newslist:[]
        };
    },
    created(){
        this.getnewslist();
    }, 
    methods:{
        // 获取新闻列表
        getnewslist(){
            this.$http.get('api/getnewslist').then(result=>{
                // 如果成功就把数据挂载到data上
                if(result.body.status===0){
                    this.newslist = result.body.message
                }else{
                    // 提示获取失败
                    Toast('获取列表失败');
                }
            })
        }
    }
}
</script>


<style lang="scss" scoped>
.mui-media-body {
  font-size: 16px;
  font-weight: 700;
  .item-title{
      font-size: 14px;
  }
  .mui-ellipsis {
    font-size: 12px;
    font-weight: 200;
    color:#26a2ff;
    display: flex;
    justify-content: space-between;
  }
}
</style>

